import com.github.davidmoten.rtree.RTree;
import com.github.davidmoten.rtree.geometry.Geometries;
import com.github.davidmoten.rtree.geometry.Rectangle;
import lzc.encrypt.IPPE;
import lzc.encrypt.encryption.Parameter;
import lzc.encrypt.rtree.ERTree;

import java.math.BigInteger;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public class Main {
    public static void main(String[] args) {
        ERTree tree = new ERTree();

        Parameter parameter = new Parameter(4, BigInteger.valueOf(/*64800*/100));
        tree.setParameterForRTree(parameter);

        int numRectangle = 10;
        for (int i = 0; i < numRectangle; i++) {
            tree.add(String.valueOf(i), getRandom());
        }

        tree.encrypt();

        Rectangle r = getRandom();
        List<Integer> result = tree.search(r);
        System.out.println(result);
    }

    public static Rectangle getRandom() {
        double minX = ThreadLocalRandom.current().nextDouble(0, 10);
        double minY = ThreadLocalRandom.current().nextDouble(0, 10);
        double maxX = ThreadLocalRandom.current().nextDouble(minX + 0.00001, 10);
        double maxY = ThreadLocalRandom.current().nextDouble(minY + 0.00001, 10);
        return Geometries.rectangle(minX, minY, maxX, maxY);
    }
}
